﻿using System.Windows.Forms;

namespace ThreadSafeControls {
    public partial class ThreadSafeComboBox : ThreadSafeControl<ComboBox> {

        private readonly ObjectCollection _items;

        internal ThreadSafeComboBox(ComboBox comboBox) : base(comboBox) {
            _items = new ObjectCollection(this);
        }

        public object DataSource {
            get { return ReturnAsync(c => c.DataSource); }
            set { UpdateAsync(c => c.DataSource = value); }
        }

        public string DisplayMember {
            get { return ReturnAsync(c => c.DisplayMember); }
            set { UpdateAsync(c => c.DisplayMember = value); }
        }

        public int DropDownHeight {
            get { return ReturnAsync(c => c.DropDownHeight); }
            set { UpdateAsync(c => c.DropDownHeight = value); }
        }

        public ComboBoxStyle DropDownStyle {
            get { return ReturnAsync(c => c.DropDownStyle); }
            set { UpdateAsync(c => c.DropDownStyle = value); }
        }

        public int DropDownWidth {
            get { return ReturnAsync(c => c.DropDownWidth); }
            set { UpdateAsync(c => c.DropDownWidth = value); }
        }

        public bool DroppedDown {
            get { return ReturnAsync(c => c.DroppedDown); }
            set { UpdateAsync(c => c.DroppedDown = value); }
        }

        public ObjectCollection Items {
            get { return _items; }
        }

        public int SelectedIndex {
            get { return ReturnAsync(c => c.SelectedIndex); }
            set { UpdateAsync(c => c.SelectedIndex = value); }
        }

        public object SelectedItem {
            get { return ReturnAsync(c => c.SelectedItem); }
            set { UpdateAsync(c => c.SelectedItem = value); }
        }

        public string SelectedText {
            get { return ReturnAsync(c => c.SelectedText); }
            set { UpdateAsync(c => c.SelectedText = value); }
        }

        public object SelectedValue {
            get { return ReturnAsync(c => c.SelectedValue); }
            set { UpdateAsync(c => c.SelectedValue = value); }
        }

        public int SelectionLength {
            get { return ReturnAsync(c => c.SelectionLength); }
            set { UpdateAsync(c => c.SelectionLength = value); }
        }

        public int SelectionStart {
            get { return ReturnAsync(c => c.SelectionStart); }
            set { UpdateAsync(c => c.SelectionStart = value); }
        }

        public string ValueMember {
            get { return ReturnAsync(c => c.ValueMember); }
            set { UpdateAsync(c => c.ValueMember = value); }
        }

    }
}
